Best Python code snippet using localstack_python
Settings.py
Source:Settings.py  
...87            return value88        return "irc.fengestad.no"89    @classmethod90    @memoize91    def get_base_dir(cls):92        path = cls.base_dir93        #if "base_dir" in cls.settings.keys():94        #    path = cls.get("base_dir")95        if not path:96            path = os.path.join(fs.get_documents_dir(True), "FS-UAE")97        if not os.path.exists(path):98            os.makedirs(path)99        path = get_real_case(path)100        return path101    @classmethod102    def get_default_search_path(cls):103        paths = []104        paths.append(cls.get_base_dir())105        #paths.append(os.path.join(fs.get_home_dir(),106        #        "Games", "Amiga"))107        #paths.append(os.path.join(fs.get_home_dir(),108        #        "Games", "CD32"))109        #paths.append(os.path.join(fs.get_home_dir(),110        #        "Games", "CDTV"))111        return paths112    @classmethod113    def get_whdload_dir(cls):114        path = os.path.join(fs.get_home_dir(), "Games", "Amiga", "WHDLoad")115        if os.path.exists(path):116            return path117        path = os.path.join(cls.get_base_dir(), "WHDLoad")118        if os.path.exists(path):119            path = get_real_case(path)120            return path121        return None122    @classmethod123    def get_configurations_dir(cls):124        path = os.path.join(cls.get_base_dir(), "Configurations")125        if not os.path.exists(path):126            os.makedirs(path)127        path = get_real_case(path)128        return path129    @classmethod130    def get_controllers_dir(cls):131        path = os.path.join(cls.get_base_dir(), "Controllers")132        path = get_real_case(path)133        return path134    @classmethod135    def get_kickstarts_dir(cls):136        path = os.path.join(cls.get_base_dir(), "Kickstarts")137        if not os.path.exists(path):138            os.makedirs(path)139        path = get_real_case(path)140        return path141    @classmethod142    def get_floppies_dir(cls):143        path = os.path.join(cls.get_base_dir(), "Floppies")144        if not os.path.exists(path):145            os.makedirs(path)146        path = get_real_case(path)147        return path148    @classmethod149    def get_hard_drives_dir(cls):150        path = os.path.join(cls.get_base_dir(), "Hard Drives")151        if not os.path.exists(path):152            os.makedirs(path)153        path = get_real_case(path)154        return path155    @classmethod156    def get_cdroms_dir(cls):157        path = os.path.join(cls.get_base_dir(), "CD-ROMs")158        if not os.path.exists(path):159            os.makedirs(path)160        path = get_real_case(path)161        return path162    @classmethod163    def get_logs_dir(cls):164        path = os.path.join(cls.get_base_dir(), "Logs")165        if not os.path.exists(path):166            os.makedirs(path)167        path = get_real_case(path)168        return path169    @classmethod170    def get_launcher_dir(cls):171        path = os.path.join(cls.get_base_dir(), "Launcher")172        if not os.path.exists(path):173            os.makedirs(path)174        path = get_real_case(path)175        return path176    @classmethod177    def get_titles_dir(cls):178        path = os.path.join(cls.get_base_dir(), "Titles")179        return path180    @classmethod181    def get_save_states_dir(cls):182        path = os.path.join(cls.get_base_dir(), "Save States")183        if not os.path.exists(path):184            os.makedirs(path)185        path = get_real_case(path)186        return path187    @classmethod188    def get_screenshots_dir(cls):189        path = os.path.join(cls.get_base_dir(), "Screenshots")190        return path191    @classmethod192    def get_images_dir(cls):193        path = cls.get_base_dir()194        return path195    @classmethod196    def get_covers_dir(cls):197        path = os.path.join(cls.get_base_dir(), "Covers")198        return path199    @classmethod200    def get_themes_dir(cls):201        path = os.path.join(cls.get_base_dir(), "Themes")202        if not os.path.exists(path):203            os.makedirs(path)204        return path205    #@classmethod206    #def get_config_dirs(cls):207    #    paths = [cls.get_floppies_dir(), cls.get_cdroms_dir(),208    #             os.path.expanduser("~/Games/Amiga/Files"),209    #             os.path.expanduser("~/Games/CD32/Files"),210    #             os.path.expanduser("~/Games/CDTV/Files")]211    #    return paths212    @classmethod213    def get_files_dirs(cls):214        paths = [cls.get_floppies_dir(), cls.get_cdroms_dir(),215                 os.path.expanduser("~/Games/Amiga/Files/"),...choro_data.py
Source:choro_data.py  
...5import geopandas as gpd6#################################################################7# Load Data8k = 'Summary Ejectment'9df_tract_m1 = pd.read_csv(f'{fn.get_base_dir()}/data/evictions_tract_months.csv')10df_tract_m2 = pd.read_csv(f'{fn.get_base_dir()}/data/evictions_tract_months_2000_2011.csv')11df_tract_m2.tract = df_tract_m2.tract.replace(1.0, 9801.0)12df_tract_m2['status_date'] = df_tract_m2['status_date'].apply(fn.datestrconv)13df_tract_m = pd.concat([df_tract_m1,df_tract_m2], sort=False)14df_tract_m = df_tract_m.fillna(0)15df_tract_m = df_tract_m.sort_values(by=['year'])16df_tract_y1 = pd.read_csv(f'{fn.get_base_dir()}/data/dataworksnc_housing_summary_ejectments__tract__year.csv')17df_tract_y2 = pd.read_csv(f'{fn.get_base_dir()}/data/dataworksnc_housing_summary_ejectments__tract__year_2000_2011.csv')18df_tract_y = df_tract_y2.merge(df_tract_y1, right_on='fips', left_on='fips', how='outer')19df_blockg_m1 = pd.read_csv(f'{fn.get_base_dir()}/data/evictions_blockgroup_months.csv')20df_blockg_m2 = pd.read_csv(f'{fn.get_base_dir()}/data/evictions_blockgroup_months_2000_2011.csv')21df_blockg_m2['status_date'] = df_blockg_m2['status_date'].apply(fn.datestrconv)22df_blockg_m = pd.concat([df_blockg_m1,df_blockg_m2], sort=False)23df_blockg_m = df_blockg_m.fillna(0)24df_blockg_m = df_blockg_m.sort_values(by=['year'])25df_blockg_y1 = pd.read_csv(f'{fn.get_base_dir()}/data/dataworksnc_housing_summary_ejectments__blockgroup__year.csv')26df_blockg_y2 = pd.read_csv(f'{fn.get_base_dir()}/data/dataworksnc_housing_summary_ejectments__blockgroup__year_2000_2011.csv')27df_blockg_y = df_blockg_y2.merge(df_blockg_y1, right_on='fips', left_on='fips', how='outer')28df_date1 = pd.read_csv(f'{fn.get_base_dir()}/data/evictionslatlong.csv')29df_date2 = pd.read_csv(f'{fn.get_base_dir()}/data/evictionslatlong_2000_2011.csv')30df_date2['status_date'] = df_date2['status_date'].apply(fn.datestrconv)31df_date = pd.concat([df_date1,df_date2])32gdf_tract = gpd.read_file(f'{fn.get_base_dir()}/data/durham_tracts/durhamtracts.shp')33gdf_blockg = gpd.read_file(f'{fn.get_base_dir()}/data/durham_blockgroups/durhamblockgroups.shp')34#---------------------------------------------------------------#35# Manipulate Data for Plotting36df_tract_m = df_tract_m.query('process == @k')37df_blockg_m = df_blockg_m.query('process == @k')38temp1 = df_tract_m[['fips','tract']]39temp1 = temp1.drop_duplicates()40temp1.reset_index(drop=True)41temp2 = df_blockg_m[['fips','tract', 'blockgroup']]42temp2 = temp2.drop_duplicates()43temp2.reset_index(drop=True)44df_tract_m = df_tract_m.drop(['docket_num', 'year', 'month', 'process', 'tract', 'status_date'], axis=1)45df_tract_m = df_tract_m.groupby('fips').sum()46df_tract_m.reset_index(level=0, inplace=True)47tract_month = df_tract_m.merge(temp1, left_on='fips', right_on='fips')48df_blockg_m = df_blockg_m.drop(['docket_num', 'year', 'month', 'process', 'tract', 'blockgroup', 'status_date'], axis=1)49df_blockg_m = df_blockg_m.groupby('fips').sum()50df_blockg_m.reset_index(level=0, inplace=True)51blockg_month = df_blockg_m.merge(temp2, left_on='fips', right_on='fips')52tract_year = df_tract_y.merge(temp1, left_on='fips', right_on='fips')53blockg_year = df_blockg_y.merge(temp2, left_on='fips', right_on='fips')54gdf_t = gdf_tract[['fips', 'geometry', 'area__sqmi']]55gdf_bg = gdf_blockg[['fips', 'geometry', 'area__sqmi']]56for i in range(len(gdf_t)):57    gdf_t.fips[i] = int(gdf_t.fips[i]) # convert fips into integer58for i in range(len(gdf_bg)):59    gdf_bg.fips[i] = int(gdf_bg.fips[i]) # convert fips into integer60#---------------------------------------------------------------#61# Grab and Convert Coords from Shapefile62gdf_t['poly_x'] = gdf_t.apply(fn.getPolyCoords, coord_type='x', axis=1)63gdf_t['poly_y'] = gdf_t.apply(fn.getPolyCoords, coord_type='y', axis=1)64gdf_t['xs'] = gdf_t.poly_x.map(fn.conv_poly_xs)65gdf_t['ys'] = gdf_t.poly_y.map(fn.conv_poly_ys)66gdf_bg['poly_x'] = gdf_bg.apply(fn.getPolyCoords, coord_type='x', axis=1)67gdf_bg['poly_y'] = gdf_bg.apply(fn.getPolyCoords, coord_type='y', axis=1)68gdf_bg['xs'] = gdf_bg.poly_x.map(fn.conv_poly_xs)69gdf_bg['ys'] = gdf_bg.poly_y.map(fn.conv_poly_ys)70#---------------------------------------------------------------#71# Merge Evictions Dataset with Shapefile72mdf1 = gdf_t.merge(tract_month, right_on='fips', left_on='fips', how='outer')73mdf2 = gdf_t.merge(tract_year, right_on='fips', left_on='fips', how='outer')74mdf3 = gdf_bg.merge(blockg_month, right_on='fips', left_on='fips', how='outer')75mdf4 = gdf_bg.merge(blockg_year, right_on='fips', left_on='fips', how='outer')76#---------------------------------------------------------------#77# Output Pickle78mdf1.to_pickle(f'{fn.get_base_dir()}/pickled_files/mdf1.pkl')79mdf2.to_pickle(f'{fn.get_base_dir()}/pickled_files/mdf2.pkl')80mdf3.to_pickle(f'{fn.get_base_dir()}/pickled_files/mdf3.pkl')81mdf4.to_pickle(f'{fn.get_base_dir()}/pickled_files/mdf4.pkl')...win32_file_utils.py
Source:win32_file_utils.py  
...10    '''11    Return the total number of blocks remaining.12    '''13    if sys.platform == "win32":14        sectPerCluster, bytesPerSector, freeClusters, totalClusters = win32file.GetDiskFreeSpace(get_base_dir())15        return totalClusters16    else:17        return os.statvfs(get_base_dir()).f_blocks181920def blocks_remaining():21    '''22    Return the total number of blocks available.23    '''24    if sys.platform == "win32":25        sectPerCluster, bytesPerSector, freeClusters, totalClusters = win32file.GetDiskFreeSpace(get_base_dir())26        return freeClusters27    else:28        return os.statvfs(get_base_dir()).f_bavail293031def total_bytes():32    '''33    Return the size of the file system in bytes.34    '''35    if sys.platform == "win32":36        sectPerCluster, bytesPerSector, freeClusters, totalClusters = win32file.GetDiskFreeSpace(get_base_dir())37        return sectPerCluster * bytesPerSector * totalClusters38    else:39        stats = os.statvfs(get_base_dir())40        return stats.f_frsize * stats.f_blocks414243def bytes_remaining():44    '''45    Return the number of bytes available on the system.46    '''47    if sys.platform == "win32":48        sectPerCluster, bytesPerSector, freeClusters, totalClusters = win32file.GetDiskFreeSpace(get_base_dir())49        return sectPerCluster * bytesPerSector * totalClusters50    else:51        stats = os.statvfs(get_base_dir())52        return stats.f_frsize * stats.f_bavail535455def percent_remaining():56    '''57    Return the percent (as a number between 0 and 1)58    available for writing on the file system.59    '''60    if sys.platform == "win32":61        return 1.062        # simulated63        sectPerCluster, bytesPerSector, freeClusters, totalClusters = win32file.GetDiskFreeSpace(get_base_dir())64        return sectPerCluster * bytesPerSector * totalClusters65    else:66        stats = os.statvfs(get_base_dir())67        return 1.0 * stats.f_bavail / stats.f_blocks686970def percent_used():71    '''72    Return the percent (as a number between 0 and 1)73    of the blocks currently used.74    '''75    return 1.0 - percent_remaining()767778if __name__ == '__main__':
...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
