Skip to content

Commit aaab42a

Browse files
committed
Update
1 parent f795a81 commit aaab42a

19 files changed

Lines changed: 975 additions & 95 deletions

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ repos:
5757
args: ['--dialect=mysql', '--exclude-rules=ambiguous.column_count, layout.long_lines, references.keywords']
5858

5959
- repo: https://github.com/astral-sh/ruff-pre-commit
60-
rev: v0.15.22
60+
rev: v0.16.0
6161
hooks:
6262
- id: ruff
63-
args: ['--fix', '--exit-non-zero-on-fix', '--ignore=B007,B023,C408,D103,E203,E266,E402,E501,F821,S105,S110,S310,SIM105'] # ruff-pre-commit does not recognize these rule selectors: B902,CM001,S410,SCS109,W503,W504
63+
args: ['--fix', '--exit-non-zero-on-fix', '--ignore=B007,B023,BLE001,C408,D103,E203,E266,E402,E501,F821,S105,S110,S310,SIM105'] # ruff-pre-commit does not recognize these rule selectors: B902,CM001,S410,SCS109,W503,W504
6464
- id: ruff-format
6565
args: ['--line-length=220', '--config', "format.quote-style='single'", '--config', "format.indent-style='space'"]
6666

documents/file-management/rename-paths.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414

1515

1616
# Import packages
17-
import os
1817
import glob
19-
from pathlib import Path
18+
import os
2019
import re
21-
20+
from pathlib import Path
2221

2322
# Settings
2423

@@ -41,23 +40,23 @@ def rename_paths(*, pattern, repl, preview=True):
4140
if len(files_rename) > 0:
4241
print('Files to be renamed:')
4342
print('\n'.join(files_rename))
44-
print('')
43+
print()
4544

4645
else:
4746
print('No files to be renamed.')
48-
print('')
47+
print()
4948

5049
# Filter for folders with specific regular expression pattern
5150
folders_rename = [path for path in paths if os.path.isdir(path) and re.search(pattern=pattern, string=Path(path).name, flags=0)]
5251

5352
if len(folders_rename) > 0:
5453
print('Folders to be renamed:')
5554
print('\n'.join(folders_rename))
56-
print('')
55+
print()
5756

5857
else:
5958
print('No folders to be renamed.')
60-
print('')
59+
print()
6160

6261
# Rename files
6362
if len(files_rename) > 0:
@@ -85,7 +84,7 @@ def rename_paths(*, pattern, repl, preview=True):
8584
if preview is False:
8685
path.rename(target=path_name_new)
8786

88-
print('')
87+
print()
8988

9089
# Rename folders
9190
if len(folders_rename) > 0:
@@ -107,7 +106,7 @@ def rename_paths(*, pattern, repl, preview=True):
107106
if preview is False:
108107
path.rename(target=path_name_new)
109108

110-
print('')
109+
print()
111110

112111

113112
##############

documents/microsoft-planner-tools/microsoft-planner-transform.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414

1515

1616
# Import packages
17-
from datetime import datetime
1817
import os
1918
import shutil
19+
from datetime import datetime
2020

21+
import pandas as pd
22+
import xlwings as xw
2123
from openpyxl import load_workbook
2224
from openpyxl.utils import get_column_letter
2325
from openpyxl.worksheet.table import Table, TableStyleInfo
24-
import pandas as pd
25-
import xlwings as xw
26-
2726

2827
###########
2928
# Functions
@@ -190,7 +189,7 @@ def microsoft_planner_transform(
190189
):
191190
"""Create a tasks summary for the most recent export and compare both existing and new tasks marked as completed during each month, saving the output as a Microsoft Excel file."""
192191
# Create variables
193-
execution_start = datetime.now()
192+
execution_start = datetime.now().astimezone()
194193

195194
# Check if the output file needs to be copied to the output directory
196195
if os.path.dirname(input_filepath) != output_path:
@@ -325,7 +324,7 @@ def microsoft_planner_transform(
325324
startcol=0,
326325
)
327326

328-
print('')
327+
print()
329328
print(f"'{file_name}' file was updated in the '{output_path}' folder.")
330329

331330
else:
@@ -358,7 +357,7 @@ def microsoft_planner_transform(
358357
freeze_panes=(1, 0),
359358
)
360359

361-
print('')
360+
print()
362361
print(f"'{file_name}' file was created and saved to the '{output_path}' folder.")
363362

364363
if len(microsoft_planner_checklists_df) > 0:
@@ -404,8 +403,8 @@ def microsoft_planner_transform(
404403
app.quit()
405404

406405
# Execution time
407-
print('')
408-
print(f'Execution time: {datetime.now() - execution_start}')
406+
print()
407+
print(f'Execution time: {datetime.now().astimezone() - execution_start}')
409408

410409

411410
def microsoft_excel_pivot_table_refresh(*, input_filepath, sheet_name, pivot_table_name):
@@ -423,11 +422,11 @@ def microsoft_excel_pivot_table_refresh(*, input_filepath, sheet_name, pivot_tab
423422
# Save the workbook back to the file
424423
workbook.save(filename=input_filepath)
425424

426-
print('')
425+
print()
427426
print(f"Pivot table '{pivot_table_name}' was refreshed.")
428427

429428
else:
430-
print('')
429+
print()
431430
print(f"Pivot table '{pivot_table_name}' was not found.")
432431

433432

documents/microsoft-planner-tools/requirements-packages.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

documents/speech-to-text/speech-to-text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
# Import packages
1717
import os
18-
import speech_recognition as sr
19-
from pydub import AudioSegment
2018
from datetime import datetime
2119

20+
import speech_recognition as sr
21+
from pydub import AudioSegment
2222

2323
###########
2424
# Functions
@@ -43,7 +43,7 @@ def speech_to_text(*, mp3_path, output_directory, language):
4343
# Recognize the speech
4444
try:
4545
text = recognizer.recognize_google(audio_data=audio_data, language=language)
46-
output_file_path = os.path.join(output_directory, f'recognized_text_{datetime.now().strftime("%Y%m%d_%H%M%S")}.txt')
46+
output_file_path = os.path.join(output_directory, f'recognized_text_{datetime.now().astimezone().strftime("%Y%m%d_%H%M%S")}.txt')
4747
with open(file=output_file_path, mode='w', encoding='utf-8') as file_out:
4848
file_out.write(text)
4949
print(f'Text saved to {output_file_path}')

finances/dkb-bank-transactions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
# Import packages
1717
import os
1818

19-
import pandas as pd
2019
import numpy as np
21-
20+
import pandas as pd
2221

2322
##############
2423
# Transactions

geographic-information-systems/geocoder/geocoder-examples.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414

1515

1616
# Import packages
17-
from importlib.util import spec_from_file_location
1817
import os
1918
import sys
19+
from importlib.util import spec_from_file_location
2020

21-
from geopy.extra.rate_limiter import RateLimiter
22-
from geopy.geocoders import Nominatim
2321
import overpy
2422
import pandas as pd
25-
23+
from geopy.extra.rate_limiter import RateLimiter
24+
from geopy.geocoders import Nominatim
2625

2726
# Import custom packages
2827
sys.dont_write_bytecode = True

geographic-information-systems/geocoder/geocoder-tools-examples.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414

1515

1616
# Import packages
17-
from importlib.util import spec_from_file_location
1817
import os
1918
import sys
19+
from importlib.util import spec_from_file_location
2020

2121
import pandas as pd
2222

23-
2423
# Import custom packages
2524
sys.dont_write_bytecode = True
2625

geographic-information-systems/geocoder/geocoder-tools.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414

1515

1616
# Import packages
17+
import os
1718
from datetime import datetime
1819
from io import BytesIO
19-
import os
20-
from zipfile import ZipFile, ZIP_DEFLATED
20+
from zipfile import ZIP_DEFLATED, ZipFile
2121

2222
import geopandas as gpd
2323
import pandas as pd
2424
import requests
2525

26-
2726
###########
2827
# Functions
2928
###########
@@ -81,7 +80,7 @@ def geocoder_country_code(*, df, shapefile_path):
8180

8281
if world_boundaries.crs == 'EPSG:4326':
8382
# Create variables
84-
execution_start = datetime.now()
83+
execution_start = datetime.now().astimezone()
8584
df_len = len(df)
8685

8786
df = (
@@ -96,7 +95,7 @@ def geocoder_country_code(*, df, shapefile_path):
9695
)
9796

9897
# Execution time
99-
print(f'Execution time: {datetime.now() - execution_start}')
98+
print(f'Execution time: {datetime.now().astimezone() - execution_start}')
10099

101100
if len(df) == df_len:
102101
# Return objects

geographic-information-systems/geocoder/geocoder.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
from datetime import datetime
1414
from itertools import batched
1515

16+
import pandas as pd
1617
from geopy.extra.rate_limiter import RateLimiter
1718
from geopy.geocoders import Nominatim
18-
import pandas as pd
19-
2019

2120
# Settings
2221

@@ -161,7 +160,7 @@ def geocoder(
161160
):
162161
"""Given a DataFrame input with location columns, split it into multiple chunks and run the geocoder, saving all chunks where the geocoder has already been run as a pickle file."""
163162
# Create variables
164-
execution_start = datetime.now()
163+
execution_start = datetime.now().astimezone()
165164

166165
for column in df.columns[df.columns.str.startswith('address_')].tolist():
167166
# Remove leading/trailing whitespaces
@@ -335,7 +334,7 @@ def geocoder(
335334
df_geolocation = None
336335

337336
# Execution time
338-
print(f'Execution time: {datetime.now() - execution_start}')
337+
print(f'Execution time: {datetime.now().astimezone() - execution_start}')
339338

340339
# Return objects
341340
return df_geolocation

0 commit comments

Comments
 (0)