Upload files to 'studio'

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2020-11-28 08:06:27 +00:00
parent 18dfef6f17
commit b4d3524b07

View file

@ -4,6 +4,8 @@
import os
import datetime
#from studio import checklist
import checklist
def get_legacy(project_location):
@ -104,6 +106,8 @@ def get_legacy(project_location):
# But first let's record a scene if it has no scene in it.
if not "<scene>" in eventtext:
if eventname in data["scenes"]:
@ -114,10 +118,9 @@ def get_legacy(project_location):
"position":eventpositon,
"size":eventsize,
"parent":"", # For when it's in a Frame (Event)
"links":{}, # Assets, Images, Files etc.
"shots":{},
"frases":{}, # For dialogues.
"text":eventtext
"shots":[[
"text_block",[["text", eventtext]]
]]
}
else:
@ -139,35 +142,308 @@ def get_legacy(project_location):
for scene in eventtext.split("</scene>")[:-1]:
scenename = scene[scene.find('"')+1:scene.replace('"'," ",1).find('"')]
scenetext = scene[scene.find('"')+2:-1]
scenetext = scene[scene.replace('"', " ", 1).find('"')+1:-1]
# Okay so we have both scene name and scene text. So it's
# time so send this data into the main data thingy, right?
# Wrong. Now we need to parse pointers to the shots, assets
# and other stuff. This file format gonna take a while.
data["scenes"][scenename] = {
"fraction":0.0, # Percentage
"position":eventpositon,
"size":eventsize,
"parent":"", # For when it's in a Frame (Event)
"shots":[[
"text_block",[["text", scenetext]]
]]
}
# Parsing the text inside the scenes... OMG. Finding the SHOTS.
for scenename in data["scenes"]:
scenetext = data["scenes"][scenename]["shots"][0][1][0][1]
# Okay so we have both scene name and scene text. So it's
# time so send this data into the main data thingy, right?
# Wrong. Now we need to parse pointers to the shots, assets
# and other stuff. This file format gonna take a while.
# If you look into the history of this file on NotABug there
# Will be a version with a novel-long article here in the
# comments. I was toying with ideas of how to make stuff
# work. I will not change the whole system a bit from what
# I though there. (Using text pointers) and make it more like
# list of shot_block or text_block. Which both are just text.
# But one has a bit more metadata then the other. And inside
# which you can specify links, frases, images and simple text...
# So first of all we need to break the text up into shots.
shots = []
sa = scenetext.count("<shot>") # Shots amount
ts = scenetext # Copy of the scene text to butcher
for s in range(sa):
# If the first part of the scene is not a shot.
if not ts.startswith("<shot>"):
shots.append([
"text_block", [["text",ts[:ts.find("<shot>")]]]
])
# Now we need to erase the part from the ts.
ts = ts[ts.find("<shot>")+6:]
# Now we can parse the shot itself. We need the name.
if ts.count('"') > 1:
shotname = ts[ts.find('"')+1:ts.replace('"', " ", 1).find('"')]
ts = ts[ts.replace('"', " ", 1).find('"')+1:]
else:
shotname = "Unnamed"
# Put it also into the list.
shots.append([
"shot_block", shotname, [["text",ts[:ts.find("</shot>")]]]
])
# And erase it.
ts = ts[ts.find("</shot>")+7:]
shots.append([
"text_block", [["text",ts]]
])
# Now I want to get a fraction from a scene.
shotsfractions = []
for shot in shots:
if shot[0] == "shot_block":
# I guess we should do it one by one. Using the technique
# from the Blender-Organizer.
# Let's see if it has a checklist.
# This step requires a huge concentration because a good
# amount of bugs can be created by not thinking about
# all kinds of ways that the user might input stuff into
# the story editor.
if os.path.exists(project_location\
+"/rnd/"+scenename+"/"+shot[1]+"/shot.progress"):
check = checklist.get_list(project_location+"/project.progress")
shotsfractions.append(check["fraction"])
else:
folder = project_location\
+"/rnd/"+scenename+"/"+shot[1]
try:
if len(os.listdir(folder+"/rendered")) > 0:
shotsfractions.append(1.0)
elif len(os.listdir(folder+"/test_rnd")) > 0:
shotsfractions.append(0.8)
elif len(os.listdir(folder+"/opengl")) > 0:
shotsfractions.append(0.6)
elif len(os.listdir(folder+"/storyboard")) > 0:
shotsfractions.append(0.4)
elif len(os.listdir(folder+"/extra")) > 0:
shotsfractions.append(0.2)
except:
shotsfractions.append(0.0)
# Writting parsed verions of the scenes. With all the shots
data["scenes"][scenename]["shots"] = shots
# Now that we have SHOTS Fractions we need a scene fraction.
try:
data["scenes"][scenename]["fraction"] = \
sum(shotsfractions) / len(shotsfractions)
except:
data["scenes"][scenename]["fraction"] = 0.0
# Now since we have shots and we have their factors. I'd like to do
# parsing of the text parts inside shots and texts between shots to
# find all the images, links and phrases.
for scenename in data["scenes"]:
for shotnum, shot in enumerate(data["scenes"][scenename]["shots"]):
# Our shot data could be either text_block ot shot_block
# and they are formatted a little bit differently.
if shot[0] == "shot_block":
text = shot[2][0][1]
else:
text = shot[1][0][1]
# Now keep in mind that similar stuff has to be done again
# when we saving the parsed text back
textblock = []
# This requires some extreme cleverness. Since I already hate
# this file format. WHY IS IT SO COMPLICATED?!
part = ""
skip = 0
for num, letter in enumerate(text):
# Basically the idea is to read the part of the story from
# beginning to end and gradually removing tags from it.
# Oh no... I'ts harder then I thought. I think we will have
# to make quite an algorythm here. If I remove <shot> from
# the text. I just removed 6 characters. If I do that again
# later with <item> it's another 6 characters. So any
# pointer system will be terrible with this kind of thing.
# Also imagine typing while having this kind of system.
# On each new typed character. ALL the pointers should be
# off setted. Hm... I think here is where I take a nap.
# Because this decision should not be done quickly. I need
# to figure out how to store this data.
if num >= skip:
if part.endswith("<item>"):
# putting the normal text in
if part[skip:].replace("<item>", ""):
textblock.append([
"text", part[skip:].replace("<item>", "")
])
# parsing the item
itempart = text[num:text[num:].find("</item>")+num]
link = itempart[itempart.find('"')+1:
itempart.replace('"', " ", 1).find('"')]
if link.startswith("/dev"):
link = link[4:]
itemtext = itempart[itempart.replace('"', " ", 1).find('"')+1:]
# puttin the link into the list
textblock.append([
"link", link, itemtext
])
# skiping to after the item
skip = text[num:].find("</item>")+6
part = ""
# Images. With the <>
elif part.endswith("<image>"):
# putting the normal text in
if part[skip:].replace("<image>", ""):
textblock.append([
"text", part[skip:].replace("<image>", "")
])
# parsing the item
link = text[num:text[num:].find("</image>")+num]
textblock.append([
"image", link
])
# skiping to after the item
skip = text[num:].find("</image>")+7
part = ""
# Images. With the [] (a little older version but still
# should be supported by default)
elif part.endswith("[image]"):
# putting the normal text in
if part[skip:].replace("[image]", ""):
textblock.append([
"text", part[skip:].replace("[image]", "")
])
# parsing the item
link = text[num:text[num:].find("[/image]")+num]
textblock.append([
"image", link
])
# skiping to after the item
skip = text[num:].find("[/image]")+7
part = ""
# Now let's figure out the frases. Because it has a
# text based thing in the beginning. Or maybe it's going
# to be anything that was before it? Hmm...
elif part.endswith(" - ["):
# putting the normal text in
if part[skip:].replace(" - [", ""):
textblock.append([
"text", part[skip:].replace(" - [", "")
])
# I designed the - [ thing to type conversation
# easier. Example:
# John - [Hello, World.]
# This would be John saying the words "Hello, World."
# but with the inclusion of <item> it became quite a
# problem. Because I would like John to be a link.
# It ended up looking something like:
#<itme>"/dev/chr/John"John</item> - [Hello, World.]
# This is a bit of a problem. Because any link that
# marked as <item> is already in a textblock list.
character = []
# If it's a link
if textblock[-1][0] == "link":
character = textblock[-1]
del textblock[-1]
# If it's just a text
elif textblock[-1][0] == "text":
character = textblock[-1][1]
character = character[character.rfind("\n")+1:]
if character:
textblock[-1][1] = textblock[-1][1].replace(character, "")
character = ["text", character]
# Now let's get the frase
frase = text[num:text[num:].find("]")+num]
# If any character. Put it into a textblock
if character:
textblock.append([
"frase", character, frase
])
# skiping to after the item
skip = text[num:].find("]")
part = ""
else:
part = part + letter
if shot[0] == "shot_block":
data["scenes"][scenename]["shots"][shotnum][2] = textblock
else:
data["scenes"][scenename]["shots"][shotnum][1] = textblock
# Okay this was event. LOL. This is a large function to parse them all.
# Crazy complex bastards. Anyway. It's over. And we have to only do the
# easy rest of it. Untill we will get to calculating the project. Because
# we need to filter out all scenes that are not in the main chain.
return data
this = get_legacy("/home/vcs/Projects/Films/Shorts/MoriasRace")
@ -177,7 +453,7 @@ for i in this:
for b in this[i]:
print(" ", b, " { ")
for c in this[i][b]:
print(" ", c ," : ", str(this[i][b][c])[:50])
print(" ", c ," : ", this[i][b][c])
print("}")
else:
print(i, " : " ,this[i])
print(i, " : " ,this[i])