comments and tidy

This commit is contained in:
2023-11-03 16:54:29 +02:00
parent c7cb8ece2e
commit fc60bde3ec
4 changed files with 11 additions and 66 deletions

View File

@@ -159,8 +159,6 @@ def write_and_commit(files, message):
try:
with open(filepath, mode, **kwargs) as f:
print(f"WRITING {cwd}---{filename} ")
# as the wsgi process www-data, we have group write-access but are not owner, so cannot chmod.
# os.chmod(filepath, 0o664) # set file permissions to rw-rw-r--
f.write(content)
except PermissionError:
raise WriteAndCommitError(
@@ -278,61 +276,6 @@ def writetrogglefile(filepath, filecontent):
# not catching and re-raising any exceptions yet, inc. the stderr etc.,. We should do that.
# def save_carefully(objectType, coUniqueAttribs={}, otherAttribs={}):
# """Looks up instance using coUniqueAttribs and carries out the following:
# -if instance does not exist in DB: add instance to DB, return (new instance, True)
# -if instance exists in DB and was modified using Troggle: do nothing, return (existing instance, False)
# -if instance exists in DB and was not modified using Troggle: overwrite instance, return (instance, False)
# The checking is accomplished using Django's get_or_create and the new_since_parsing boolean field
# defined in core.models.TroggleModel.
# We are not using new_since_parsing - it is a fossil from Aaron Curtis's design in 2006. So it is always false.
# NOTE: this takes twice as long as simply creating a new object with the given values.
# As of Jan.2023 this function is not used anywhere in troggle.
# """
# try:
# instance, created = objectType.objects.get_or_create(defaults=otherAttribs, **coUniqueAttribs)
# except:
# print(" !! - FAIL in SAVE CAREFULLY ===================", objectType)
# print(" !! - -- objects.get_or_create()")
# print(f" !! - coUniqueAttribs:{coUniqueAttribs}\n !! - otherAttribs:{otherAttribs}")
# raise
# if not created and not instance.new_since_parsing:
# for k, v in list(
# otherAttribs.items()
# ): # overwrite the existing attributes from the logbook text (except date and title)
# setattr(instance, k, v)
# try:
# instance.save()
# except:
# print(" !! - SAVE CAREFULLY ===================", objectType)
# print(" !! - -- instance.save()")
# print(f" !! - coUniqueAttribs:{coUniqueAttribs}\n !! - otherAttribs:{otherAttribs}")
# raise
# try:
# str(instance)
# except:
# pass
# if created:
# logging.info(str(instance) + " was just added to the database for the first time. \n")
# if not created and instance.new_since_parsing:
# logging.info(
# str(instance) + " has been modified using Troggle since parsing, so the current script left it as is. \n"
# )
# if not created and not instance.new_since_parsing:
# logging.info(
# " instance:<"
# + str(instance)
# + "> existed in the database unchanged since last parse. It have been overwritten."
# )
# return (instance, created)
"""The following is a Bard converted version of Radosts's MIT copyrighted Javascript on 2023-10-27
with hand-editing.