Skip to content

Sourcery Starbot ⭐ refactored bwlambert/planetscraper#1

Open
SourceryAI wants to merge 1 commit intobwlambert:masterfrom
SourceryAI:master
Open

Sourcery Starbot ⭐ refactored bwlambert/planetscraper#1
SourceryAI wants to merge 1 commit intobwlambert:masterfrom
SourceryAI:master

Conversation

@SourceryAI
Copy link
Copy Markdown

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch https://github.com/sourcery-ai-bot/planetscraper master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment thread create_report.py
# names in the given directory
listOfFile = os.listdir(dirName)
allFiles = list()
allFiles = []
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function getListOfFiles refactored with the following changes:

Comment thread create_report.py
Comment on lines -124 to +133
allFiles = list()
allFiles = []
# Iterate over all the entries
for entry in listOfFile:
# Create full path
fullPath = os.path.join(dirName, entry)
# If entry is a directory then get the list of files in this directory
# If entry is a directory then get the list of files in this directory
if os.path.isdir(fullPath):
allFiles = allFiles + getListOfFiles(fullPath)
else:
if regex.match(fullPath):
allFiles.append(fullPath)
elif regex.match(fullPath):
allFiles.append(fullPath)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function getListOfMetadataFiles refactored with the following changes:

Comment thread order_api.py

def get_remaining_quota():
leftquota = 0.0
leftquota = 0.0
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_remaining_quota refactored with the following changes:

Comment thread order_api.py
Comment on lines -81 to +96

lbuf = 0.0025#0.01
xbuf = lbuf#/2.0
mn = 0
totalm2 = 0.0
for pp in geometryX:
listarray = []
#listarray.append([pp.x, pp.y])
listarray.append([pp.x+xbuf, pp.y-lbuf])
listarray.append([pp.x-xbuf, pp.y-lbuf])
listarray.append([pp.x-xbuf, pp.y+lbuf])
listarray.append([pp.x+xbuf, pp.y+lbuf]) # self intersection?
listarray = [
[pp.x + xbuf, pp.y - lbuf],
[pp.x - xbuf, pp.y - lbuf],
[pp.x - xbuf, pp.y + lbuf],
[pp.x + xbuf, pp.y + lbuf],
]

nparray = np.array(listarray)
poly = geometry.Polygon(nparray)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calculate_sqkm refactored with the following changes:

This removes the following comments ( why? ):

# self intersection?
#listarray.append([pp.x, pp.y])

Comment thread order_api.py
Comment on lines -117 to +132

gjlist= []
lbuf = 0.01
xbuf = lbuf#/2.0
mn = 0
totalm2 = 0.0
for pp in geometryX:
listarray = []
#listarray.append([pp.x, pp.y])
listarray.append([pp.x+xbuf, pp.y-lbuf])
listarray.append([pp.x-xbuf, pp.y-lbuf])
listarray.append([pp.x-xbuf, pp.y+lbuf])
listarray.append([pp.x+xbuf, pp.y+lbuf]) # self intersection?
listarray = [
[pp.x + xbuf, pp.y - lbuf],
[pp.x - xbuf, pp.y - lbuf],
[pp.x - xbuf, pp.y + lbuf],
[pp.x + xbuf, pp.y + lbuf],
]

nparray = np.array(listarray)
poly = geometry.Polygon(nparray)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function generate_geojson_from_coords_df refactored with the following changes:

This removes the following comments ( why? ):

#print(json.dumps(g1,indent=1))
#print(mn)
# self intersection?
#listarray.append([pp.x, pp.y])

Comment thread order_api.py
Comment on lines -369 to +349
result = \
requests.get(
hp,
auth=HTTPBasicAuth(PLANET_API_KEY, '')
)
return(result)
return requests.get(hp, auth=HTTPBasicAuth(PLANET_API_KEY, ''))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_requestv2_results refactored with the following changes:

Comment thread order_api.py
Comment on lines -384 to +363
loc_ids = []
for order in r2js['orders']:
if(order['name']==name):
loc_ids.append(order["_links"]["_self"])
return(loc_ids)
return [
order["_links"]["_self"]
for order in r2js['orders']
if (order['name'] == name)
]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function extract_location_ids refactored with the following changes:

Comment thread order_api.py
Comment on lines -401 to +376
#dres = spec_result['_links']
act_ids = [order['location'] for order in dres['results']]
return(act_ids)
return [order['location'] for order in dres['results']]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_download_url refactored with the following changes:

This removes the following comments ( why? ):

#dres = spec_result['_links']

Comment thread order_api.py
Comment on lines -464 to +437
l=gdf.distance(gdf.shift())
return(l)
return gdf.distance(gdf.shift())
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function lldist refactored with the following changes:

Comment thread order_api.py
Comment on lines -564 to +548

print("Loading Planet API key from key.txt")
with open('key.txt', 'r') as file:
PLANET_API_KEY = file.read().replace('\n', '')

locfile = sys.argv[1]
if locfile == "resume":
resume_and_sync()
exit()
if locfile == "quota":
get_remaining_quota()
exit()

elif locfile == "resume":
resume_and_sync()
exit()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 564-653 refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant