Skip to content

Commit

Permalink
text fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhong5297 committed Nov 29, 2023
1 parent 9514f75 commit 1191899
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/pull_from_dune.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@
print('UPDATE: existing query file: {}'.format(found_files[0]))
with open(file_path, 'r+', encoding='utf-8') as file:
#if "query repo:" is in the file, then don't add the text header again
if '-- already part of a query repo' in query.sql:
if '-- part of a query repo' in query.sql:
file.write(query.sql)
else:
file.write(f'-- already part of a query repo\n-- query name: {query.base.name}\n-- query link: https://dune.com/queries/{query.base.query_id}\n\n\n{query.sql}')
file.write(f'-- part of a query repo\n-- query name: {query.base.name}\n-- query link: https://dune.com/queries/{query.base.query_id}\n\n\n{query.sql}')
else:
# Create new file and directories if they don't exist
new_file = f'{query.base.name.replace(" ", "_").lower()[:30]}___{query.base.query_id}.sql'
file_path = os.path.join(os.path.dirname(__file__), '..', 'queries', new_file)
os.makedirs(os.path.dirname(file_path), exist_ok=True)

if '-- already part of a query repo' in query.sql:
print('WARNING!!! This query is already part of a query repo')
if '-- part of a query repo' in query.sql:
print('WARNING!!! This query is part of a query repo')
with open(file_path, 'w', encoding='utf-8') as file:
file.write(f'-- WARNING: this query may be part of multiple repos\n{query.sql}')
else:
with open(file_path, 'w', encoding='utf-8') as file:
file.write(f'-- already part of a query repo\n-- query name: {query.base.name}\n-- query link: https://dune.com/queries/{query.base.query_id}\n\n\n{query.sql}')
file.write(f'-- part of a query repo\n-- query name: {query.base.name}\n-- query link: https://dune.com/queries/{query.base.query_id}\n\n\n{query.sql}')
print('CREATE: new query file: {}'.format(new_file))


Expand Down

0 comments on commit 1191899

Please sign in to comment.