-
Notifications
You must be signed in to change notification settings - Fork 2
Sourcery refactored main branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ def format_size(size): | |
| # Specify the directory path you want to count files in | ||
| directory_path = "PineScripts" | ||
|
|
||
| file_count = sum([len(files) for _, _, files in os.walk(directory_path)]) | ||
| file_count = sum(len(files) for _, _, files in os.walk(directory_path)) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| directory_size = get_directory_size(directory_path) | ||
|
|
||
| print(f"The number of files in '{directory_path}' is: {file_count}") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| page = 1 | ||
|
|
||
| while True: | ||
| url = base_url + f'page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
| url = f'{base_url}page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| response = requests.get(url) | ||
| soup = BeautifulSoup(response.content, 'html.parser') | ||
|
|
||
|
|
@@ -39,7 +39,7 @@ | |
|
|
||
| # Extract PineScript code | ||
| script_url = item.find('a', class_='tv-widget-idea__title').get('href') | ||
| script_full_url = 'https://www.tradingview.com' + script_url | ||
| script_full_url = f'https://www.tradingview.com{script_url}' | ||
|
|
||
| # Open the script page with Firefox | ||
| driver.get(script_full_url) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
| base_url = 'https://www.tradingview.com/scripts/editors-picks/' | ||
|
|
||
| async def download_page(session, page): | ||
| url = base_url + f'page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
| url = f'{base_url}page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| async with session.get(url) as response: | ||
| content = await response.text() | ||
|
|
@@ -60,7 +60,7 @@ async def download_page(session, page): | |
|
|
||
| # Extract PineScript code | ||
| script_url = item.find('a', class_='tv-widget-idea__title').get('href') | ||
| script_full_url = 'https://www.tradingview.com' + script_url | ||
| script_full_url = f'https://www.tradingview.com{script_url}' | ||
|
|
||
| # Open the script page with Firefox | ||
| driver.get(script_full_url) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
| base_url = 'https://www.tradingview.com/scripts/indicators/' | ||
|
|
||
| async def download_page(session, page): | ||
| url = base_url + f'page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
| url = f'{base_url}page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| async with session.get(url) as response: | ||
| content = await response.text() | ||
|
|
@@ -60,7 +60,7 @@ async def download_page(session, page): | |
|
|
||
| # Extract PineScript code | ||
| script_url = item.find('a', class_='tv-widget-idea__title').get('href') | ||
| script_full_url = 'https://www.tradingview.com' + script_url | ||
| script_full_url = f'https://www.tradingview.com{script_url}' | ||
|
|
||
| # Open the script page with Firefox | ||
| driver.get(script_full_url) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ | |
| base_url = 'https://www.tradingview.com/scripts/' | ||
|
|
||
| def download_page(page): | ||
| url = base_url + f'page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
| url = f'{base_url}page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| response = requests.get(url) | ||
| soup = BeautifulSoup(response.content, 'html.parser') | ||
|
|
||
|
|
@@ -44,7 +44,7 @@ def download_page(page): | |
|
|
||
| # Extract PineScript code | ||
| script_url = item.find('a', class_='tv-widget-idea__title').get('href') | ||
| script_full_url = 'https://www.tradingview.com' + script_url | ||
| script_full_url = f'https://www.tradingview.com{script_url}' | ||
|
|
||
| # Open the script page with Firefox | ||
| driver.get(script_full_url) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
| base_url = 'https://www.tradingview.com/scripts/' | ||
|
|
||
| async def download_page(session, page): | ||
| url = base_url + f'page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
| url = f'{base_url}page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| async with session.get(url) as response: | ||
| content = await response.text() | ||
|
|
@@ -60,7 +60,7 @@ async def download_page(session, page): | |
|
|
||
| # Extract PineScript code | ||
| script_url = item.find('a', class_='tv-widget-idea__title').get('href') | ||
| script_full_url = 'https://www.tradingview.com' + script_url | ||
| script_full_url = f'https://www.tradingview.com{script_url}' | ||
|
|
||
| # Open the script page with Firefox | ||
| driver.get(script_full_url) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ | |
| base_url = 'https://www.tradingview.com/scripts/strategies/' | ||
|
|
||
| async def download_page(session, page): | ||
| url = base_url + f'page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
| url = f'{base_url}page-{page}/?script_type=strategies&script_access=open&sort=month_popular&route_range=1' | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| async with session.get(url) as response: | ||
| content = await response.text() | ||
|
|
@@ -60,7 +60,7 @@ async def download_page(session, page): | |
|
|
||
| # Extract PineScript code | ||
| script_url = item.find('a', class_='tv-widget-idea__title').get('href') | ||
| script_full_url = 'https://www.tradingview.com' + script_url | ||
| script_full_url = f'https://www.tradingview.com{script_url}' | ||
|
|
||
| # Open the script page with Firefox | ||
| driver.get(script_full_url) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
clean_pinescriptrefactored with the following changes:nextinstead of a for-loop (use-next)use-named-expression)inline-immediately-returned-variable)This removes the following comments ( why? ):