Skip to content

Commit

Permalink
Minor changes (typo fixing, increase consistency)
Browse files Browse the repository at this point in the history
Fixed a missing closing bracket inside a string
Removing brackets in print statements to increase consistency
Change how to open file in non-main script to increase consistency
  • Loading branch information
essut committed Nov 2, 2016
1 parent 4b15c55 commit d217fa7
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions simbad_extractor.py
Expand Up @@ -83,7 +83,7 @@ def magnitude(dic, filename, path):
elt_index = read_file.index("<star>")
elt_len = len("<star>")
except ValueError: # ie free floating planet (no star or parent)
print '{} failed (no parent object tag'.format(filename)
print '{} failed (no parent object tag)'.format(filename)
return False


Expand Down Expand Up @@ -196,14 +196,13 @@ def spectralType(spectre, filename, path):
#the list is in correct format and won't bring any troubles.
#However, as it is a copy/paste of the script, it should work.
def generateList(path):
planet_list = open("list.txt", "w")
for filename in glob.glob(path+"/*.xml"):
# Open file
name = os.path.split(filename)
name = name[1]
name = name.replace(".xml","")
planet_list.write(name+"\n")
planet_list.close()
with open("list.txt", "w") as planet_list:
for filename in glob.glob(path+"/*.xml"):
# Open file
name = os.path.split(filename)
name = name[1]
name = name.replace(".xml","")
planet_list.write(name+"\n")



Expand All @@ -229,13 +228,13 @@ def generateList(path):
try:
code_source = urllib.urlopen('http://simbad.u-strasbg.fr/simbad/sim-basic?Ident='+planet).read()
except IOError:
print('Lookup failed - sleeping for 10 seconds')
print 'Lookup failed - sleeping for 10 seconds'
time.sleep(10)

try:
code_source = urllib.urlopen('http://simbad.u-strasbg.fr/simbad/sim-basic?Ident='+planet).read()
except IOError:
print('Lookup failed again for {} - skipping'.format(planet))
print 'Lookup failed again for {} - skipping'.format(planet)
log.write('Lookup failed for {}'.format(planet))

#First check its existence on simbad
Expand Down

0 comments on commit d217fa7

Please sign in to comment.