mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
fixing more misnamed file stuff
This commit is contained in:
parent
36ef9f961d
commit
c18ebeb992
1
mvscript.sh
Normal file
1
mvscript.sh
Normal file
@ -0,0 +1 @@
|
||||
cd /home/philip/expoweb/cave_data
|
@ -556,10 +556,12 @@ def read_entrance(filename, ent=None):
|
||||
ent.save()
|
||||
return ent
|
||||
|
||||
def read_cave(filename, cave=None):
|
||||
def read_cave(filename, mvf, cave=None):
|
||||
"""Reads an entrance description from the .html file
|
||||
Convoluted. Sorry. Needs rewriting
|
||||
|
||||
mvf is a file handle for misnamed files
|
||||
|
||||
If not called as part of initial import, then the global lists will not be correct
|
||||
but this is OK, a search will find them in the db.
|
||||
|
||||
@ -685,18 +687,25 @@ def read_cave(filename, cave=None):
|
||||
if kataster_number:
|
||||
if slug == f"{areacode}-{kataster_number}":
|
||||
return slug
|
||||
message = f" ! Cave Slug mismatch (kataster): '{slug}' != '{areacode}-{kataster_number}' {url=} in file {filename}. Adjusting.."
|
||||
message = f" ! Cave Slug mismatch (kataster): '{slug}' != '{areacode}-{kataster_number}' {url=} in file {filename}. CHANGE caveslug field in the .html file."
|
||||
correctslug = f"{areacode}-{kataster_number}"
|
||||
|
||||
else:
|
||||
if slug == f"{areacode}-{unofficial_number}":
|
||||
return slug
|
||||
if slug.lower() == f"{areacode}-{unofficial_number.lower()}":
|
||||
message = f" ! Cave Slug capitalisation incorrect (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename}"
|
||||
message = f" ! Cave Slug capitalisation incorrect (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename}."
|
||||
correctslug = slug.lower()
|
||||
else:
|
||||
message = f" ! Cave Slug mismatch (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename}"
|
||||
message = f" ! Cave Slug mismatch (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename} CHANGE caveslug field in the .html file."
|
||||
correctslug = slug # hack to stopit crashing
|
||||
DataIssue.objects.create(parser="caves", message=message, url=f"{cave.slug}_cave_edit/")
|
||||
DataIssue.objects.create(parser="caves", message=message, url=f"{slug}_cave_edit/") # url here is for where the file actually is, for editing
|
||||
mvtext = f"mv {filename} {correctslug}.html"
|
||||
#print(mvtext)
|
||||
if filename != f"{correctslug}.html" :
|
||||
message = f" ! Filename is not the same as the cave slug '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename} so use troggle/mvscript.sh to fix."
|
||||
DataIssue.objects.create(parser="caves", message=message, url=f"{slug}_cave_edit/") # url here is for where the file actually is, for editing
|
||||
mvf.write(mvtext + "\n")
|
||||
print(message)
|
||||
return correctslug
|
||||
|
||||
@ -716,7 +725,7 @@ def read_cave(filename, cave=None):
|
||||
DataIssue.objects.create(parser="caves", message=message, url=context)
|
||||
print(message)
|
||||
return None
|
||||
|
||||
|
||||
with open(fn) as f:
|
||||
contents = f.read()
|
||||
cavecontentslist = getXML(contents, "cave", maxItems=1, context=context)
|
||||
@ -814,8 +823,8 @@ def read_cave(filename, cave=None):
|
||||
cave.url = f"{cave.areacode}/{cave.number()}/{cave.number()}.html"
|
||||
check_directory(cave.areacode, cave.number(), cave.url, cave)
|
||||
|
||||
# This next line has no effect because the cave slug is not actually a field on the Cave object so we can't fix it here. to-do.
|
||||
slug = check_slug(cave.areacode,cave.kataster_number, cave.unofficial_number, cave.url)
|
||||
# This next line has no effect because the cave slug is not actually a field on the Cave object so we can't fix it here. to-do!
|
||||
slug = check_slug(cave.areacode, cave.kataster_number, cave.unofficial_number, cave.url)
|
||||
|
||||
entrances = getXML(cavecontents, "entrance", context=context)
|
||||
do_entrances()
|
||||
@ -905,9 +914,12 @@ def readcaves():
|
||||
|
||||
with transaction.atomic():
|
||||
print(" - Reading Caves from cave descriptions xml files")
|
||||
for filename in next(os.walk(CAVEDESCRIPTIONS))[2]: # Should be a better way of getting a list of files
|
||||
if filename.endswith(".html"):
|
||||
read_cave(filename)
|
||||
mvscript = "mvscript.sh"
|
||||
with open(mvscript, "w") as mvf: # overwrite
|
||||
mvf.write(f"cd {CAVEDESCRIPTIONS}\n")
|
||||
for filename in next(os.walk(CAVEDESCRIPTIONS))[2]: # Should be a better way of getting a list of files
|
||||
if filename.endswith(".html"):
|
||||
read_cave(filename, mvf)
|
||||
|
||||
print(" - Setting up all the variously useful alias names")
|
||||
GetCaveLookup()
|
||||
|
Loading…
Reference in New Issue
Block a user